//
//  YBDownloadNineHandle.m
//  GoodBuy
//
//  Created by Cyber on 15/5/14.
//  Copyright (c) 2015年 GoodBuy. All rights reserved.
//
#import "AFNetworking.h"
#import "YBDownloadNineHandle.h"

@implementation YBDownloadNineHandle

+(instancetype)shareNineHandle
{
    static YBDownloadNineHandle *dataHandle = nil;
    if (dataHandle == nil) {
        
        dataHandle = [[YBDownloadNineHandle alloc] init];
        [dataHandle initNineData];
    }
    return dataHandle;
}

-(void)initNineData {
    AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    
    
    NSString *url_string = [NSString stringWithFormat:@"http://jkjby.repaiapp.com/jkjby/view/list_api.php"];
    
    
    //[NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  代表支持所有的接口类型
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [netWorkManager stopMonitoring];
        NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
        NSDictionary *dic1 = [[NSDictionary alloc]init];
        dic1 = responseObject;
        NSMutableArray *arr = [[NSMutableArray alloc]init];
        arr = [dic1 objectForKey:@"list"];
        
        self.allNineArray = [[NSMutableArray alloc]init];
        for (NSDictionary *dic in arr) {
            YBNineModel *nine = [[YBNineModel alloc]init];
            [nine setValuesForKeysWithDictionary:dic];
            [_allNineArray addObject:nine];
            
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        
    }];
}


@end
